﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UdrinkWater_Project.Officer
{
    public partial class OutStockDetial : System.Web.UI.Page
    {
        private string Connection = ConfigurationManager.ConnectionStrings["DB_Udrink"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
            string Date = Session["ProductDate"].ToString();
            DataTable dtOutStock = GetOutList(Date);
            txtDate.Text = dtOutStock.Rows[0]["Product_Date"].ToString();
            txtEmpId.Text = dtOutStock.Rows[0]["Act_Officer"].ToString();
            txtEmpName.Text = dtOutStock.Rows[0]["EmpName"].ToString();
            gv1.DataSource = dtOutStock;
            gv1.DataBind();
        }
        private DataTable GetOutList(string indate)
        {
            string sqltext = @"SELECT        TB_StockProductOUT.Product_Date, TB_StockProductOUT.Product_ID, TB_Product.Product_name, TB_Unit_Category.Unit_Name, TB_StockProductOUT.Product_Count,
		                        TB_StockProductOUT.Act_Officer,(TB_Employee.Prefix+' '+ TB_Employee.Firstname +' '+ TB_Employee.Lastname) AS EmpName,'ออกคลัง' AS Status
                                FROM            TB_StockProductOUT LEFT JOIN
                         TB_Product ON TB_StockProductOUT.Product_ID = TB_Product.Product_ID LEFT JOIN
                         TB_Employee ON TB_StockProductOUT.Act_Officer = TB_Employee.ID_Card LEFT JOIN
                         TB_Unit_Category ON TB_Product.Unit = TB_Unit_Category.Unit_ID
                         WHERE TB_StockProductOUT.Product_Date ='" + indate + "' ";
            SqlConnection sqlconn = new SqlConnection(Connection);
            SqlDataAdapter da = new SqlDataAdapter(sqltext, sqlconn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            return ds.Tables[0];
        }
    }
}